﻿using System;
using System.Web.Security;
using com.eforceglobal.crux.DTOs;
using com.eforceglobal.crux.contracts.Plugins;
using com.eforceglobal.crux.controllers;
using com.eforceglobal.crux.configuration;

public partial class Controls_Common_Logout : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        SessionData sessionData = new SessionData();
        UserInformation user = sessionData.CurrentUser;
        IProcessor<UserInformation> plugObject = (IProcessor<UserInformation>)CruxConfigurationManager.GetProcessor("LogoutProcessor");
        if (plugObject != null)
        {
            plugObject.FirePreprocessAction(user);
        } 
        sessionData.CurrentUser = null;
        sessionData.CurrentView = null;
        sessionData.CurrentViewSection = null;
        FormsAuthentication.SignOut();
        if (plugObject != null)
        {
            plugObject.FirePostprocessAction(user);
        } 
        NavigationController.OpenView(CruxConfigurationManager.GetApplicationDefaultView());
    }
}
